package me.shenfan.updateapp;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by BlingBling on 16/9/19.
 */

public class UpdateSharedPreferences {
    private static final String PREFERENCES_NAME = "UpdateSharedPreferences";
    private static final String NEW_VERSION_NAME = "NEW_VERSION_NAME";
    private static final String IGNORE_VERSION_NAME = "IGNORE_VERSION_NAME";
    private static final String FILE_LENGTH = "FILE_LENGTH";

    private SharedPreferences mPreferences;

    public UpdateSharedPreferences(Context context) {
        mPreferences = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
    }

    public void setNewVersionName(String versionName) {
        mPreferences.edit().putString(NEW_VERSION_NAME, versionName).commit();
    }

    public String getNewVersionName() {
        return mPreferences.getString(NEW_VERSION_NAME, "-1");
    }

    public void setIgnoreVersionName(String versionName) {
        mPreferences.edit().putString(IGNORE_VERSION_NAME, versionName).commit();
    }

    public String getIgnoreVersionName() {
        return mPreferences.getString(IGNORE_VERSION_NAME, "-1");
    }

    public void setFileLength(long fileSize) {
        mPreferences.edit().putLong(FILE_LENGTH, fileSize).commit();
    }

    public long getFileLength() {
        return mPreferences.getLong(FILE_LENGTH, -1);
    }
}
